package sensor;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class WeatherSensor extends Sensor {
    private double temperature;
    private double humidity;
    private double windSpeed;
    private final Random random = new Random();

    public WeatherSensor() {
        this.temperature = 20 + random.nextDouble() * 10;
        this.humidity = 40 + random.nextDouble() * 30;
        this.windSpeed = 2 + random.nextDouble() * 5;
    }

    @Override
    public void notifyObservers(double data) {
        temperature = 20 + random.nextDouble() * 10;
        humidity = 40 + random.nextDouble() * 30;
        windSpeed = 2 + random.nextDouble() * 5;
        notifyObservers("温度: " + temperature + ", 湿度: " + humidity + ", 风速: " + windSpeed);
    }
}